<?php

class Application_Form_Admin_RechargeForm extends Zend_Form {

	public function init() {
		$this->setName('recharge');
		
		$this->setMethod(Zend_Form::METHOD_POST)
		->setEnctype(Zend_Form::ENCTYPE_URLENCODED);
		
		$autocomplete = new ZendX_JQuery_Form_Element_AutoComplete('user');
		$autocomplete->setFilters(array('StripTags'))
		->setJQueryParams(array(
		'autoFill' => true,
		'source' => 'searchusers',
		'minLength' => 3,
		'delay' => 100,
		'select' => new Zend_Json_Expr('function(event,ui) { displayInfo(ui.item.value) }'),
		'search' => new Zend_Json_Expr('function(event,ui) { removeInfo() }'),
		))
		->setDecorators(array('UiWidgetElement','FormErrors','Label','Errors'))
		->setAttrib("class", "menu-input");

		$montant = new Zend_Form_Element_Text('montant');
		$montant->setLabel('Montant de la recharge : ')
		->addValidator('NotEmpty')
		->setValue(0)
		->setDecorators(array('ViewHelper','FormErrors','Errors','Label'))
		->setAttrib("class", "menu-input")
		->setAttrib("autocomplete", "off")
		->setAttrib("onKeyup", "updateSolde($('#montant').val())");

		$libelle = new Zend_Form_Element_Text('libelle');
		$libelle->setLabel('Commentaire : ')
		->addValidator('NotEmpty')
		->setDecorators(array('ViewHelper','FormErrors','Errors','Label'))
		->setAttrib("class", "menu-input");

		$send = new Zend_Form_Element_Submit('send');
		$send->setAttrib('id','send_button')
		->setLabel('Enregistrer')
		->setAttrib('class','button')
		->setDecorators(array('ViewHelper','FormErrors','Errors'));
		
		
		$this->addElements(array($autocomplete,$montant,$libelle,$send));
	}
}